<?php
include_once("config.php");
if (isset($_SESSION['adminName'])){
	$isAdmin=true;
}else{
	$isAdmin=false;
}
$query="SELECT * FROM restaurant";
$result=mysql_query($query);
?>

<!DOCTYPE html>
<html>
<head>
	<title>View Restuarant | Admin</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<link rel="stylesheet" type="text/css" href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css">
	<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
	<script type="text/javascript" src="//netdna.bootstrapcdn.com/bootstrap/3.0.2/js/bootstrap.min.js"></script>
</head>
<body>
<?php
if (!$isAdmin){
  header("location: adminIndex.php");
}else{
?>
  <div class="container">
  	<nav class="navbar navbar-inverse" role="navigation">
		  <!-- Brand and toggle get grouped for better mobile display -->
		  <div class="navbar-header">
		    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapse-1">
		      <span class="icon-bar"></span>
		      <span class="icon-bar"></span>
		      <span class="icon-bar"></span>
		      <span class="icon-bar"></span>
		    </button>
		    <a class="navbar-brand" href="adminIndex.php">Admin Index</a>
		  </div>

		  <!-- Collect the nav links, forms, and other content for toggling -->
		  <div class="collapse navbar-collapse" id="navbar-collapse-1">
		    <ul class="nav navbar-nav">
		      <li><a href="viewuser.php">User</a></li>
		      <li><a href="viewrestuarant.php">Restuarant</a></li>
		      <li><a href="viewdish.php">Dish</a></li>
		      <li><a href="vieworder.php">Order</a></li>
		    </ul>
		    <ul class="nav navbar-nav navbar-right">
          <li><a href="adminLogout.php">Logout</a></li>
		    </ul>
		  </div><!-- /.navbar-collapse -->
		</nav>
		<div class="table-responsive">
			<table class="table table-hover">
			  <thead>
					<tr>
						<td>Name</td>
						<td>Address</td>
						<td>Averrage consumption</td>
						<td>Cuisines</td>
						<td>Contact Number</td>
						<td>Description</td>
						<td>Delete</td>
						<td>Update</td>
					</tr>
				</thead>
				
				<tbody>
					<?php
					while ($row=mysql_fetch_array($result)) {
						echo "<tr>";
						echo "<td>".$row['name']."</td>";
						echo "<td>".$row['address']."</td>";
						echo "<td>".$row['argC']."</td>";
						echo "<td>".$row['cuisines']."</td>";
						echo "<td>".$row['contactNum']."</td>";
						echo "<td>".$row['description']."</td>";
						echo "<td>";
						echo "<form action='deleterestuarant.php' method='post'>";
						echo "<input type='hidden' name='restuarantaddress' value='".$row['address']."'>";
						echo "<button type='submit' class='btn btn-danger'>Delete</button>";
						echo "</form>";
						echo "</td>";
						echo "<td>";
						echo "<form action='updaterestuarant.php' method='post'>";
						echo "<input type='hidden' name='restuarantaddress' value='".$row['address']."'>";
						echo "<button type='submit' class='btn btn-warning'>Update</button>";
						echo "</form>";
						echo "</td>";
						echo "</tr>";
					}
					?>
				</tbody>
			</table>
		</div>
		<form class="form-horizontal" role="form" action="addrestuarant.php" method="post">
		  <div class="form-group">
		    <label class="col-sm-2 control-label">Restuarant Name</label>
		    <div class="col-sm-10">
		      <input type="text" class="form-control" name="restuarantname" placeholder="New Restuarant Name">
		    </div>
		  </div>
		  <div class="form-group">
		    <label class="col-sm-2 control-label">Restuarant Address</label>
		    <div class="col-sm-10">
		      <input type="text" class="form-control" name="restuarantaddress" placeholder="New Restuarant Address">
		    </div>
		  </div>
		  <div class="form-group">
		    <label class="col-sm-2 control-label">Average Consumption</label>
		    <div class="col-sm-10">
		      <input type="text" class="form-control" name="restuarantaverageconsumption" placeholder="New Average Consumption">
		    </div>
		  </div>
		  <div class="form-group">
		    <label class="col-sm-2 control-label">Cuisines</label>
		    <div class="col-sm-10">
		      <input type="text" class="form-control" name="restuarantcuisines" placeholder="New Restuarant Cuisines">
		    </div>
		  </div>
		  <div class="form-group">
		    <label class="col-sm-2 control-label">Contact Number</label>
		    <div class="col-sm-10">
		      <input type="text" class="form-control" name="restuarantcontactnumber" placeholder="New Restuarant Contact Number">
		    </div>
		  </div>
		  <div class="form-group">
		    <label class="col-sm-2 control-label">Description</label>
		    <div class="col-sm-10">
		      <input type="text" class="form-control" name="restuarantdescription" placeholder="New Restuarant Description">
		    </div>
		  </div>
		  <div class="form-group">
		    <div class="col-sm-offset-2 col-sm-10">
		      <button type="submit" class="btn btn-success">Add Restuarant</button>
		    </div>
		  </div>
		</form>
  </div>
<?php
}
?>
</body>
</html>
